#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
用户领域接口

定义用户领域的服务和仓储接口
"""

from abc import abstractmethod
from typing import Any, Dict, List, Optional

from app.core.interfaces import Repository, Service
from .model import User


class IUserRepository(Repository[User]):
    """用户仓储接口"""
    
    @abstractmethod
    def get_by_username(self, username: str) -> Optional[User]:
        """根据用户名获取用户
        
        Args:
            username: 用户名
            
        Returns:
            User: 用户对象或None
        """
        pass
    
    @abstractmethod
    def get_by_email(self, email: str) -> Optional[User]:
        """根据邮箱获取用户
        
        Args:
            email: 邮箱
            
        Returns:
            User: 用户对象或None
        """
        pass
    
    @abstractmethod
    def update_token(self, user_id: str, token: str) -> bool:
        """更新用户令牌
        
        Args:
            user_id: 用户ID
            token: 令牌
            
        Returns:
            bool: 操作是否成功
        """
        pass
    
    @abstractmethod
    def batch_create(self, users: List[User]) -> List[User]:
        """批量创建用户
        
        Args:
            users: 用户列表
            
        Returns:
            List[User]: 创建成功的用户列表
        """
        pass


class IUserService(Service[User]):
    """用户服务接口"""
    
    @abstractmethod
    def get_by_username(self, username: str) -> Optional[User]:
        """根据用户名获取用户"""
        pass
    
    @abstractmethod
    def get_by_email(self, email: str) -> Optional[User]:
        """根据邮箱获取用户"""
        pass
    
    @abstractmethod
    def batch_create_users(self, count: int, password: str) -> tuple:
        """批量创建用户
        
        Args:
            count: 用户数量
            password: 密码
            
        Returns:
            tuple: (成功数量, 失败数量, 用户列表)
        """
        pass
    
    @abstractmethod
    def update_user_token(self, user_id: str, token: str) -> bool:
        """更新用户令牌"""
        pass 